package com.litbw.publicobservable;

/**
 * 
 * The Message interface is a basic template for the information that is
 * useful to send as a "message" (argument) through the Observable method
 * notifyObservers(Object).<BR><BR>
 * It is recommended that sub classes extend SimpleMessage rather than implement
 * this interface, to retain desired recipient class functionality.
 * 
 * @author Michael Morris
 *
 */
public interface Message {

	/**
	 * Retrieve the desired recipient class saved with this message. This
	 * method should be strictly followed so that messages intended ONLY for
	 * a specific class type will indeed be the only class who takes action.  
	 * @return A Class reference which can be compared by either
	 * <code>getClass().equals(..)</code> or 
	 * <strong><code>instanceof</code></strong>.<BR><BR>
	 * NOTE: If the Observable used null as a recipient class the return value
	 * should be that of java.lang.Object, which is ANY object.
	 */
	@SuppressWarnings("rawtypes")
	Class getRecipientClass();
	
	/**
	 * Recipient class should be filled by an Observable when the message
	 * being sent should ONLY be viewed by a certain class.<BR><BR>
	 * For instance, say there is are 3 different subclasses of ObservablePanel
	 * that work with login/logout message (i.e. they should take some action
	 * based on whether the user is logged in/out). You could create ONE logout
	 * message instance and simply set this to a specific (one of the three)
	 * recipient class. This way the same message could be sent (requires less
	 * subclassing) and only the desired 1/3 of the ObservablePanels that deal
	 * with logout messages will take action.
	 * @param c The class (<code>classname.getClass()</code>) of the desired
	 * recipient. Null to fill in Class with java.lang.Object.
	 */
	@SuppressWarnings("rawtypes")
	void setRecipientClass(final Class c);
}
